from flask import Flask
from flask_cors import CORS
from app.config.config import Config
from app.api.nav_routes import nav_bp
from app.api.form_routes import form_bp

def create_app(config_class=Config):
    """创建Flask应用实例"""
    app = Flask(__name__)
    
    # 加载配置
    app.config.from_object(config_class)
    
    # 初始化配置
    config_class.init_app()
    
    # 配置CORS
    CORS(app)
    
    # 注册蓝图
    app.register_blueprint(nav_bp, url_prefix=f"{config_class.API_PREFIX}/nav")
    app.register_blueprint(form_bp, url_prefix=f"{config_class.API_PREFIX}/form")
    
    return app 